﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace VLog
{
    /// <summary>
    /// 日志生产工厂
    /// </summary>
    public class VLogFactory
    {
        /// <summary>
        /// 创建日志对象
        /// </summary>
        /// <returns></returns>
        public static VLogBase CreateVLog()
        {
            if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["VLog"]))
                return new NullVLog();

            return (VLogBase)System.Reflection.Assembly
                 .Load("VLog")
                 .CreateInstance("VLog." + ConfigurationManager.AppSettings["VLog"]);
        }

        /// <summary>
        /// 根据记录方式，去创建日志对象
        /// </summary>
        /// <param name="logType"></param>
        /// <returns></returns>
        public static VLogBase CreateVLog(LogType logType)
        {
            return (VLogBase)System.Reflection.Assembly
                .Load("VLog")
                .CreateInstance("VLog." + logType.ToString());
        }
    }
}
